<template>
    <div>
        <van-cell-group title="申请详情">
            <van-cell title="申请人" :value="form.applyname" />
            <van-cell title="手机号码" :value="form.applymobile"/>
            <van-cell title="申请时间" :value="form.applytime"/>
        </van-cell-group>

        <van-cell-group title="提示">
            <p class="tip-p">
                请认真核对用户是否为本企业成员，同意加入企业组后，该用户即可在“工程保函通”平台使用本企业的基本资料。
            </p>
        </van-cell-group>

        <div class="btn-group_bottom">
            <van-button type="warning" @click="clickHandler(3)">驳回申请</van-button>
            <van-button type="primary" @click="clickHandler(1)">同意加入</van-button>
        </div>
    </div>
</template>

<script>
    import axios from 'axios'
    import Qs from 'qs'

    export default {
        data() {
            return {
                form: {}
            }
        },
        computed: {
            userid() {
                return this.getQuery('userid')
            }
        },
        methods: {
            clickHandler(type) {
                var query = {
                    userid: this.userid,
                    shbj: type
                };

                this.$axios({
                    url: '/usermg/joinsh.json',
                    data: Qs.stringify(query),
                    method: 'post',
                }).then(data => {
                    this.$toast.success('操作完成');

                    if(type === 1) {
                        this.goto('./list')
                    } else {
                        this.$router.replace({
                            path: '/info',
                            query: {
                                title: '操作完成'
                            }
                        });
                    }
                });
            }
        },
        mounted() {
            this.GetOpenID(() => {
                var query = {
                    userid: this.userid
                };
                this.$axios({
                    url: '/usermg/joingroupdetail.json',
                    data: Qs.stringify(query),
                    method: 'post',
                }).then(data => {
                    this.form = data;
                });
            });
        }
    }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.btn-group_bottom{position:fixed; left:0; bottom:0; width:100%; overflow:hidden;}
.btn-group_bottom .van-button{width:50%; float:left;}

.tip-p{color:red; padding:10px 15px;}
</style>
